package com.geely.controller;

import java.util.List;

import com.geely.model.User;
import com.geely.validator.UserValidator;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;

public class AdmUserController extends Controller 
{
	public void index() 
	{	
		List<User> user=User.dao.getAllUser();
		setAttr("user", user);
		render("/User/index.html");
	}
	
	public void add()
	{
		render("/User/add.html");
	}
	
	public void edit() 
	{		
		User user=User.dao.findById(getParaToInt(0));
    	setAttr("user", user);
        render("/User/edit.html"); 
	}
	@Before(UserValidator.class)
	public void update() 
	{
		getModel(User.class).update();
		redirect("/admUser"); 
	}
	@Before(UserValidator.class)
	public void save() 
	{
		getModel(User.class).save();
		redirect("/admUser");
	}
}
